#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QTcpSocket>
#include "pack.h"
#include <QMessageBox>
#include "interface.h"
#include <QFile>

QT_BEGIN_NAMESPACE
namespace Ui {
class Widget;
}
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
    void handleLoginResponse(const Pack& pack);
    bool eventFilter(QObject *obj, QEvent *event);
    Interface* getInterface();

private slots:
    void on_pushButton_connect_clicked();

    void on_pushButton_login_clicked();

private:
    Ui::Widget *ui;
    QTcpSocket* client;
    QHostAddress ip;
    int port;

    Interface* face;

    Pack readed_pack;
    int readed_pack_size = 0;
    int unreaded_pack_size = 0;
    int readed_size = 0;
    int readed_size_size = 0;
    int unreaded_size_size = 0;

private slots:
    void onReadyRead();
    void on_pushButton_register_clicked();
};
#endif // WIDGET_H
